How can i be sure that a dxl script delete an object in a module where i have the full permission and it's open in edit mode? The attached script fail if i have an object with children. It deletes all children, all the links but It doesn't delete the father object and it returns "object has descendants".
p.s. can you tell me the tag for inserting the code in a post?
bungle_77 - Mon Jun 17 09:46:00 EDT 2013 |
Re: Delete an Object Francesco, I can't answer the DXL question, but to put code in a post, use the blockquote formatting - about half way along the second row of buttons, just after indent and outdent. I will post your script below.
|
Re: Delete an Object Hello, The first thing I noticed is that the source module of the incoming links needs to be saved in order for the link to actually be removed. Not sure if this has anything to do with the object has descendents though. Greg |
Re: Delete an Object GregM_dxler - Mon Jun 17 10:49:37 EDT 2013 Hello, The first thing I noticed is that the source module of the incoming links needs to be saved in order for the link to actually be removed. Not sure if this has anything to do with the object has descendents though. Greg it's not that the problem, i can delete an object even without saveing the source module
thanks Hazel |
Re: Delete an Object bungle_77 - Mon Jun 17 11:04:58 EDT 2013 it's not that the problem, i can delete an object even without saveing the source module
thanks Hazel i tried this script on an Object A with two children A1 and A2. with an outcoming link from A to A1 and A2. and each of these 3 objects has in and out links to other objects |
Re: Delete an Object bungle_77 - Tue Jun 18 04:20:06 EDT 2013 i tried this script on an Object A with two children A1 and A2. with an outcoming link from A to A1 and A2. and each of these 3 objects has in and out links to other objects i found out the error. I made the flushdeletion inside the loop "for oc in o do". I should call this function in a recursive way till it returns "object has descendants" |
Re: Delete an Object bungle_77 - Tue Jun 18 04:58:19 EDT 2013 i found out the error. I made the flushdeletion inside the loop "for oc in o do". I should call this function in a recursive way till it returns "object has descendants" i thought i solved the problem, but i still have it :-( here the new code
|
Re: Delete an Object bungle_77 - Tue Jun 18 05:52:12 EDT 2013 i thought i solved the problem, but i still have it :-( here the new code
i restricted the problem i just created a requirement with three children and no links and this simple code:
i got the same error |
Re: Delete an Object bungle_77 - Tue Jun 18 06:18:14 EDT 2013 i restricted the problem i just created a requirement with three children and no links and this simple code:
i got the same error Your latest code works for me in that an object with children all get deleted. It doesn't work if the children have children but throws a dxl error with the message object has descendents. This makes sense since the child has a child. Change the loop to the following: for oc in o do { if (null first oc) hardDelete(oc) else DeleteObjectWithChildren(oc) } This will recursively go through each level, deleting the children's children. Looks like softDelete(o) will delete the children but not the parent. Not sure why this is. The dxl help says the object is marked for deletion but not actually deleted. It doesn't look like it is marked for deletion to me, but then I didn't try to purge it afterwards either. Good luck, Greg |
Re: Delete an Object GregM_dxler - Tue Jun 18 09:57:25 EDT 2013 Your latest code works for me in that an object with children all get deleted. It doesn't work if the children have children but throws a dxl error with the message object has descendents. This makes sense since the child has a child. Change the loop to the following: for oc in o do { if (null first oc) hardDelete(oc) else DeleteObjectWithChildren(oc) } This will recursively go through each level, deleting the children's children. Looks like softDelete(o) will delete the children but not the parent. Not sure why this is. The dxl help says the object is marked for deletion but not actually deleted. It doesn't look like it is marked for deletion to me, but then I didn't try to purge it afterwards either. Good luck, Greg i solved by this way:
i just made a softdeletion of the father and then i purge all the objects of the module |
Re: Delete an Object GregM_dxler - Mon Jun 17 10:49:37 EDT 2013 Hello, The first thing I noticed is that the source module of the incoming links needs to be saved in order for the link to actually be removed. Not sure if this has anything to do with the object has descendents though. Greg Not quite. "flushDeletions" needs to be executed before the target does not see the link and allows it to be deleted. Try this:
-Louie |
Re: Delete an Object Not quite following, but IIRC the following are true and must be considered by the script.
Your script I think needs to be recursive; looking like this
I think I would tend to write separate "delete" and "purge" functions, partly because they are diffferent and partly to prevent accidental destruction, when "false" was intended but "true" entered. Not that I've ever done that... -Louie Not sure how I did it years ago, but I did manage to get a module with undeleted object with a deleted parent. So some scripts need to deal with that possibility. |